package com.example.blog.mapper;

import com.example.blog.entity.Article;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

/**
 * <p>
 * 文章信息 Mapper 接口
 * </p>
 *
 * @author wlh
 * @since 2024-01-10
 */

public interface ArticleMapper extends BaseMapper<Article> {

    void updateViews(@Param("articleId") Long articleId, @Param("views") Integer views);

    @Select("select count(*) as counts, sum(article.views) as views from article where created_by = #{userId}")
    Map<String, Object> countByUser(@Param("userId") Long userId);
}
